// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false

//装载Axios
import deAxios from 'axios'
Vue.prototype.$axiosdefault = deAxios
import Axios from '@/config/axiosConfig.js'
Vue.prototype.$axios = Axios

//安装elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

let listUrl = ["login"]
//axios的响应前置拦截器
Axios.interceptors.response.use(function(param) {
    // let index = param.config.url.lastIndexOf("/")
    // let pathname = param.config.url.substr(index + 1)
    // console.log(param.config.url.substr(index + 1))
    if (param.data.code == "0" || param.data.code == "1" || param.data.code == "2") {
      //登录有问题的
      alert(param.data.message);
      //路由跳转到login去
      router.push({
        path: '/'
      })
    } else {
      return param; //放过
    }

  }),

  /* eslint-disable no-new */
  new Vue({
    el: '#app',
    router,
    components: {
      App
    },
    template: '<App/>'
  })
